<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box">
        <input type="text" placeholder="请输入用户名">
        <input type="text" placeholder="请输入密码">
        <button>登录</button>
    </div>
</body>
</html>
<script>
    function ajax (type , url , pages , fn){
        var str = ''
        for(var key in pages){
            str += `${key}=${pages[key]}&`
        }
        str = str.slice(0 , str.length - 1)

        var xhm = new XMLHttpRequest()
        xhm.open(type , type == "get" ? url + '?' + str : url)

        xhm.onreadystatechange = () => {
            if(xhm.readyState == 4){
                fn(JSON.parse(xhm.responseText))
            }
        }
        xhm.setRequestHeader('content-type' , 'application/x-www-form-urlencoded')
        xhm.send(type == 'post' ? pages : undefined)
    }

    var input = document.querySelectorAll('input')
    var btn = document.querySelector('button')

    btn.onclick = () => {
        if(
            function fcn () {}
        )
    }
</script>